package com.yht.provide.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 鱼仔
 * @date 2021/8/9 5:20 下午
 * 概要
 */
@RestController
public class TestController {

    @Autowired
    private DiscoveryClient discoveryClient;

    @GetMapping(value = "/pc")
    public String getPc() throws InterruptedException {
        String services = "Services: " + discoveryClient.getServices();
        System.out.println(services);
        // 模拟服务提供者服务延迟，是否会降级处理
        // Thread.sleep(1000L);
        // 模拟服务提供者服务异常时消费者降级处理
        // int a = 10 / 0;
        return services;
    }
}
